'use strict';

Object.defineProperty(exports, "__esModule", {
    value: true
});
exports.genSchedule = undefined;

var _genCancelNs = require('./genCancelNs');

var genSchedule = exports.genSchedule = function genSchedule(cancelNs) {
    var _cancelNs = cancelNs || (0, _genCancelNs.genCancelNs)();
    return {
        cancelNs: _cancelNs,
        timeout: function timeout(ns, fn, delay) {
            var tHandler = setTimeout(fn, delay);
            var cancel = function cancel() {
                clearTimeout(tHandler);
            };
            return _cancelNs.add(ns, fn, cancel);
        },
        interval: function interval(ns, fn, delay) {
            var tHandler = setInterval(fn, delay);
            var cancel = function cancel() {
                clearInterval(tHandler);
            };
            return _cancelNs.add(ns, fn, cancel);
        }
    };
};

exports.default = genSchedule;